<?php

/**
 * This is the model class for table "ledger".
 *
 * The followings are the available columns in table 'ledger':
 * @property integer $ledger
 * @property string $ledger_date
 * @property string $soldier_name
 * @property string $soldier_serial_number
 * @property string $ledger_status
 * @property double $credit
 * @property string $credit_date
 * @property double $debit
 * @property string $debit_date
 * @property string $date_of_occupancy
 * @property string $date_of_vacated
 * @property string $date_of_retirement
 * @property string $monthly_rental
 * @property integer $quarter_no
 * @property string $ledger_update
 * @property string $ledger_update_date
 * @property integer $employee_id
 * @property integer $solidier_id
 */
class Ledger extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Ledger the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ledger';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('soldier_name, soldier_serial_number, quarter_no, employee_id, solidier_id', 'required'),
			array('quarter_no, employee_id, solidier_id', 'numerical', 'integerOnly'=>true),
			array('credit, debit', 'numerical'),
			array('soldier_name', 'length', 'max'=>60),
			array('soldier_serial_number, ledger_status, monthly_rental, ledger_update', 'length', 'max'=>45),
			array('ledger_date, credit_date, debit_date, date_of_occupancy, date_of_vacated, date_of_retirement, ledger_update_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ledger, ledger_date, soldier_name, soldier_serial_number, ledger_status, credit, credit_date, debit, debit_date, date_of_occupancy, date_of_vacated, date_of_retirement, monthly_rental, quarter_no, ledger_update, ledger_update_date, employee_id, solidier_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ledger' => 'Ledger',
			'ledger_date' => 'Ledger Date',
			'soldier_name' => 'Soldier Name',
			'soldier_serial_number' => 'Soldier Serial Number',
			'ledger_status' => 'Ledger Status',
			'credit' => 'Credit',
			'credit_date' => 'Credit Date',
			'debit' => 'Debit',
			'debit_date' => 'Debit Date',
			'date_of_occupancy' => 'Date Of Occupancy',
			'date_of_vacated' => 'Date Of Vacated',
			'date_of_retirement' => 'Date Of Retirement',
			'monthly_rental' => 'Monthly Rental',
			'quarter_no' => 'Quarter No',
			'ledger_update' => 'Ledger Update',
			'ledger_update_date' => 'Ledger Update Date',
			'employee_id' => 'Employee',
			'solidier_id' => 'Solidier',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ledger',$this->ledger);
		$criteria->compare('ledger_date',$this->ledger_date,true);
		$criteria->compare('soldier_name',$this->soldier_name,true);
		$criteria->compare('soldier_serial_number',$this->soldier_serial_number,true);
		$criteria->compare('ledger_status',$this->ledger_status,true);
		$criteria->compare('credit',$this->credit);
		$criteria->compare('credit_date',$this->credit_date,true);
		$criteria->compare('debit',$this->debit);
		$criteria->compare('debit_date',$this->debit_date,true);
		$criteria->compare('date_of_occupancy',$this->date_of_occupancy,true);
		$criteria->compare('date_of_vacated',$this->date_of_vacated,true);
		$criteria->compare('date_of_retirement',$this->date_of_retirement,true);
		$criteria->compare('monthly_rental',$this->monthly_rental,true);
		$criteria->compare('quarter_no',$this->quarter_no);
		$criteria->compare('ledger_update',$this->ledger_update,true);
		$criteria->compare('ledger_update_date',$this->ledger_update_date,true);
		$criteria->compare('employee_id',$this->employee_id);
		$criteria->compare('solidier_id',$this->solidier_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}